import {postForm, postJSON} from '@/common/utils/request'
import {Response} from "@/common/types/env";

const SYS_MSG = '/manage/system/msg'

const SYS_ROLE = '/manage/system/role'

const SYS_MENU = '/manage/system/menu'

const SYS_USER = '/manage/system/user'

const SYS_DICT = '/manage/system/dict'

/** 角色 **/
//全部由我创建的角色
export function allMyCreateRole() {
    return postForm(`${SYS_ROLE}/allMyRole`, {})
}

// 角色分页数据
export function pageRole(param: any) {
    return postForm(`${SYS_ROLE}/pageMyRole`, param)
}

//插入数据
export function insertRole(param = {}): Promise<Response> {
    return postForm(`${SYS_ROLE}/insertRole`, param)
}

export function deleteRole(param = {}): Promise<Response> {
    return postForm(`${SYS_ROLE}/deleteRole`, param)
}

export function updateRole(param = {}): Promise<Response> {
    return postForm(`${SYS_ROLE}/updateRole`, param)
}

export function roleInfo(param = {}): Promise<Response> {
    return postForm(`${SYS_ROLE}/info`, param)
}

export function updateRoleMenu(param = {}): Promise<Response> {
    return postForm(`${SYS_ROLE}/updateRoleMenu`, param)
}

/** 菜单 **/
//刷新缓存
export function refreshMenuCache(param = {}): Promise<Response> {
    return postForm(`${SYS_MENU}/refreshMenuCache`, param)
}

//插入菜单
export function insertMenu(param = {}): Promise<Response> {
    return postForm(`${SYS_MENU}/insertMenu`, param)
}

//全部菜单
export function selectUserHasMenu(param = {}): Promise<Response> {
    return postForm(`${SYS_MENU}/userHasMenu`, param)

}

//修改菜单
export function updateMenu(param = {}): Promise<Response> {
    return postForm(`${SYS_MENU}/updateMenu`, param)
}

//修改菜单
export function deleteMenu(param = {}): Promise<Response> {
    return postForm(`${SYS_MENU}/deleteMenu`, param)
}

/** 用户 **/
// 添加用户
export function insertUser(param = {}): Promise<Response> {
    return postForm(`${SYS_USER}/insert`, param)
}

// 修改用户信息
export function updateUser(param = {}): Promise<Response> {
    return postForm(`${SYS_USER}/update`, param)
}

// 删除用户信息
export function deleteUser(param = {}): Promise<Response> {
    return postForm(`${SYS_USER}/delete`, param)
}

// 登录
export function userLogin(param = {}): Promise<Response> {
    return postForm(`${SYS_USER}/login`, param)
}

// 注册
export function userRegister(param = {}): Promise<Response> {
    return postForm(`${SYS_USER}/register`, param)
}

// 获取用户详细信息
export function selectUserInfo(param = {}): Promise<Response> {
    return postForm(`${SYS_USER}/userInfo`, param)
}

//用户分页数据
export function pageUser(param = {}): Promise<Response> {
    return postForm(`${SYS_USER}/page`, param)
}

// 获取验证码
export function captchaImg() {
    return postForm(`${SYS_USER}/captchaImage`)
}

export function resetUserPassword(param = {}): Promise<Response> {
    return postForm(`${SYS_USER}/resetUserPassword`, param)
}

export function resetMyPassword(param = {}): Promise<Response> {
    return postForm(`${SYS_USER}/resetMyPassword`, param)
}

/**
 * 字典
 */
//刷新缓存
export function insertDict(param = {}): Promise<Response> {
    return postForm(`${SYS_DICT}/insert`, param)
}

export function updateDict(param = {}): Promise<Response> {
    return postForm(`${SYS_DICT}/update`, param)
}

export function deleteDict(param = {}): Promise<Response> {
    return postForm(`${SYS_DICT}/delete`, param)
}

export function pageDict(param = {}): Promise<Response> {
    return postForm(`${SYS_DICT}/page`, param)
}

export function allDictOptionEnum(param = {}): Promise<Response> {
    return postForm(`${SYS_DICT}/allDictOptionEnum`, param)
}

export function selectDictValue(param = {}): Promise<Response> {
    return postForm(`${SYS_DICT}/dictValue`, param)
}

export function clearCache(param = {}): Promise<Response> {
    return postForm(`${SYS_DICT}/clearCache`, param)
}

//修改配置信息
export function updateSetting(param = {}): Promise<Response> {
    return postJSON(`${SYS_DICT}/updateSetting`, param)
}

export function selectSetting(param = {}): Promise<Response> {
    return postForm(`${SYS_DICT}/selectSetting`, param)
}

// 分页获取文件列表
export function filePage(param = {}): Promise<Response> {
    return postForm('/manage/file/page', param)
}

//

export function sysMsgUserPageData(param = {}): Promise<Response> {
    return postForm(`${SYS_MSG}/userPageData`, param)
}

export function sysMsgPageData(param = {}): Promise<Response> {
    return postForm(`${SYS_MSG}/msgPageData`, param)
}

export function sysMsgInsert(param = {}): Promise<Response> {
    return postForm(`${SYS_MSG}/insert`, param)
}

export function sysMsgDelete(param = {}): Promise<Response> {
    return postForm(`${SYS_MSG}/delete`, param)
}

export function sysMsgInfo(param = {}): Promise<Response> {
    return postForm(`${SYS_MSG}/info`, param)
}

export function sysMsgNotReadCount(param = {}): Promise<Response> {
    return postForm(`${SYS_MSG}/notReadMsgCount`, param)
}

export function sysMsgTopList(param = {}): Promise<Response> {
    return postForm(`${SYS_MSG}/msgTopList`, param)
}

export function sysMsgReadAll(param = {}): Promise<Response> {
    return postForm(`${SYS_MSG}/readAll`, param)
}

export function sysMsgRead(param = {}): Promise<Response> {
    return postForm(`${SYS_MSG}/read`, param)
}